package com.java01.lang.filechannel;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.channels.FileChannel;

public class CopyFileTest {

	public static void main(String[] args) {
		try {
			FileChannel sourceChannel = new FileInputStream("D:\\sourceFile").getChannel();
			FileChannel targetChannel = new FileOutputStream("D:\\targetFile").getChannel();
			targetChannel.transferFrom(sourceChannel, 0, sourceChannel.size());
			sourceChannel.close();
			targetChannel.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}